package com.magicsoft.share.presenter.my;

import com.magicsoft.share.base.BasePresenter;
import com.magicsoft.share.bean.my.InstructionModel;
import com.magicsoft.share.constant.APIService;
import com.magicsoft.share.rx_retrofit_network.location.retrofit.RetrofitUtil;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.LoadingTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.NetWorkTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.SimpleObserver;
import com.magicsoft.share.view.my.InstructionView;

/**
 * Created by lyf on 2017/11/22/022.
 */

public class InstructionPresenter extends BasePresenter<InstructionView> {

    public void instruction() {
        RetrofitUtil.getApi(APIService.class).instruction()
                .compose(new NetWorkTransformer<InstructionModel>())
                .compose(new LoadingTransformer<InstructionModel>(mContext))
                .subscribe(new SimpleObserver<InstructionModel>(mCompositeDisposable) {
                    @Override
                    public void call(InstructionModel model) {
                        getView().OnNext(model);
                    }

                    @Override
                    public void showErrorMsg(Throwable e, String errorMsg) {
                        super.showErrorMsg(e, errorMsg);
                        getView().OnError();
                    }
                });
    }
}
